#引入selenium库中的 webdriver 模块
from selenium import webdriver
from selenium.webdriver.common.by import By
#引入time库
import time

# 打开谷歌浏览器
from selenium.webdriver import ActionChains

driver = webdriver.Chrome(r'D:\tool\chromedriver_win32\chromedriver.exe')


driver.get('https://passport2.eastmoney.com/pub/login')
time.sleep(5)
html = driver.page_source

driver.switch_to.frame("frame_login")

'''
考虑到网页打开的速度取决于每个人的电脑和网速,
使用time库sleep()方法,让程序睡眠3秒
'''





driver.find_element(By.XPATH,'//*[@id="txt_mobile"]').send_keys('18668071597')
driver.find_element(By.XPATH,'/html/body/div/div[1]/span[1]').click()


#driver.find_element_by_xpath('/html/body/div/div[1]/span[1]').click()
time.sleep(1)
driver.find_element(By.XPATH,'//*[@id="txt_account"]').send_keys('18668071597')
driver.find_element(By.XPATH,'//*[@id="txt_pwd"]').send_keys('xht18668071597')
time.sleep(1)
driver.find_element(By.XPATH,'/html/body/div/form[2]/div/div[4]').click()
driver.find_element(By.XPATH,'/html/body/div/form[2]/div/div[4]/div/img[1]').click()

time.sleep(1)
driver.find_element(By.XPATH,'/html/body/div/form[1]/div/div[3]/div[1]/div/div[1]/div[2]').click()


'''
driver.find_element_by_xpath('//*[@id="txt_account"]').send_keys('88888888')
time.sleep(1)

#点击登录按钮
driver.find_element_by_xpath('//*[@id="mtqrcode_submitBtn"]').click()

time.sleep(3)

driver.find_element_by_xpath('//*[@id="mtqrcode_phone_attr"]').send_keys('1')
driver.find_element_by_xpath('//*[@id="mtqrcode_3621274002_attr"]').send_keys('1')
time.sleep(1)
driver.find_element_by_xpath('//*[@id="mtqrcode_info_btn"]').click()
'''

# 切换到父frame，相当于后退　　`driver.switch_to.parent_frame()`
# 切换到主文档　　`driver.switch_to.default_content()`